package fr.dsax.nounet.belote.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import fr.dsax.nounet.belote.dao.IDaoFactory;
import fr.dsax.nounet.belote.dao.IGenericDao;
import fr.dsax.nounet.belote.jpa.GenericEntity;

@Service
public abstract class GenericServiceImpl <T extends GenericEntity> implements GenericService<T> {
	
	@Autowired
	IDaoFactory daoFactory;
	
	private Class<T> entityType;

	@Override
	public void create(T newInstance) {
		getDao().create(newInstance);
	}

	@Override
	public T findById(Integer id) {
		return getDao().findById(id);
	}

	@Override
	public List<T> findAll() {
		return getDao().findAll();
	}

	@Override
	public void update(T transientObject) {
		getDao().update(transientObject);
		
	}

	@Override
	public void delete(T persistentObject) {
		getDao().delete(persistentObject);
	}

	public abstract IGenericDao<T> getDao();
	

}
